
export function json2Query(json) {
  let str = [];
  for (var p in json) {
    str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p]));
  }
  return str.join("&");
}

export const reqOrderId = () => {
  return "orderid";
};


export const reqFormUpload = (url, data, callBack) => {
  wx.request({
    url: url,
    method: "POST",
    data: data,
    complete: (res) => {

      console.log(res)
      callBack(res)

      if (res == null || res.data == null) {
        console.error('网络请求失败');
        callBack(null);
        return;
      }

    }

  });

};



export const reqFormPost = (url, data, callBack) => {
  console.log(data.contentType)
  wx.request({
    url: url,
    header: {
      "Content-Type": data.contentType ? "application/json" : "application/x-www-form-urlencoded"
    },
    method: "POST",
    data: data,
    complete: (res) => {

      console.log(res)
      callBack(res)

      if (res == null || res.data == null) {
        console.error('网络请求失败');
        callBack(null);
        return;
      }

    }

  });

};

export const reqUrlGet = (url, data, callBack) => {
  wx.request({
    url: url,
    header: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: "GET",
    data: data,
    complete: (res) => {

      console.log(res)
      callBack(res)

      if (res == null || res.data == null) {
        console.error('网络请求失败');
        callBack(null);
        return;
      }

    }

  });

};


export const reqJsonPost = () => {

  return "orderid";

};
